/**
 * @Title: LeaveOutAdapter.java
 * @Package: com.jason.bluetooth.fingerprint.adapter
 * @Descripton: TODO
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2014年11月9日23:32:04
 * @Version: V1.0
 */
package com.jason.platform.supervision.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.hzlj.supervision.changsha.R;
import com.jason.platform.supervision.beans.SignBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: DailySignAdapter
 * @Description: 日常签到适配器
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2015-8-8 09:14:30
 */
public class DailySignAdapter extends BaseAdapter {

	private static final String TAG = DailySignAdapter.class.getSimpleName();

	private Context mContext;
	private LayoutInflater mLayoutInflater;
	private List<SignBean> mDatas = new ArrayList<SignBean>();

	public DailySignAdapter(Context context) {
		super();
		this.mContext = context;
		this.mLayoutInflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.mDatas = new ArrayList<SignBean>();
	}

	@Override
	public int getCount() {
		return mDatas.size();
	}

	@Override
	public Object getItem(int position) {
		return mDatas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void addAll(List<SignBean> datas) {
		this.mDatas = datas;
		if (mDatas == null){
			mDatas = new ArrayList<SignBean>();
		}
		notifyDataSetChanged();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(
					R.layout.adapter_daily_sign, null);
			holder = new Holder();
			holder.mNameTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_name);
			holder.mBeginTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_begin);
			holder.mEndTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_end);
			holder.mPhoneTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_phone);
			holder.mTypeTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_type);
			holder.mGuanZhuTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_guanzhi);
			holder.mYanGuanTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_yanguan);
			holder.mOrganTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_orange);
			holder.mZaiCeTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_zaice);
			holder.mCardTextView = (TextView) convertView
					.findViewById(R.id.daily_sign_card);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		SignBean bean = (SignBean) getItem(position);
		if (bean != null){
			holder.mNameTextView.setText(bean.getElecname());
			holder.mBeginTextView.setText(bean.getStartTimeJS());
			holder.mEndTextView.setText(bean.getEndTimeJJ());
			holder.mPhoneTextView.setText(bean.getTelephone());
			holder.mTypeTextView.setText(bean.getCriminal());
			holder.mGuanZhuTextView.setText(bean.getType());
			holder.mYanGuanTextView.setText(bean.getManagelevel());
			holder.mZaiCeTextView.setText(bean.getStatus());
			holder.mCardTextView.setText("身份证:" + bean.getIdentity());
			holder.mOrganTextView.setText(bean.getOrgan());

		}
		//TODO 填充数据
		return convertView;
	}

	class Holder {
		TextView mNameTextView;
		TextView mBeginTextView;
		TextView mEndTextView;
		TextView mPhoneTextView;
		TextView mTypeTextView;
		TextView mOrganTextView;
		TextView mGuanZhuTextView;
		TextView mYanGuanTextView;
		TextView mZaiCeTextView;
		TextView mCardTextView;
	}

}
